package com.base.vistter.iframe.inverter.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.base.vistter.iframe.bean.Result;
import com.base.vistter.iframe.entity.InverterStationType;
import com.base.vistter.iframe.exception.IframeException;
import com.base.vistter.iframe.service.InverterStationTypeService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/station/type")
public class InverterStationTypeController {

    @Resource(name = "inverterStationTypeService")
    private InverterStationTypeService inverterStationTypeService;

    @GetMapping
    public Result<List<InverterStationType>> get() throws IframeException {
        LambdaQueryWrapper<InverterStationType> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.orderByAsc(InverterStationType::getSort);
        return Result.ok(inverterStationTypeService.selectList(lambdaQueryWrapper));
    }
}
